import ResMgr from "../../Framework/Scripts/Managers/ResMgr";
import SceneMgr from "../../Framework/Scripts/Managers/SceneMgr";
import UIMgr from "../../Framework/Scripts/Managers/UIMgr";
import { AbNames, SceneCfg } from "./GameCfg";

const {ccclass, property} = cc._decorator;

@ccclass
export default class GameApp extends cc.Component {

    public static Instance: GameApp = null;

    onLoad () {
        if(GameApp.Instance !== null) {
            this.destroy();
            return;
        }
        GameApp.Instance = this;
    }

    start () {

    }

    public Init(): void {
        console.log("========GameApp Init================");
    }

    public async EnterGame() {
        console.log("EnterGame #######");
        // 由其它开发者来接管整个游戏项目的代码编写;
        // SceneMgr.Instance.EnterScene(SceneCfg.lanch); // 如果你把场景当作是ab包的，那么加载不到;
        // end
 
        // 写一些框架的测试代码，方便代码使用常用的一些模块
        // end

        //测试加载资源
        let ab = await ResMgr.Instance.IE_LoadBundle(AbNames.Game) as cc.AssetManager.Bundle;
        console.log("========GameApp EnterGame================",ab);

        let path = "AssetPackage/Prefabs/UILogin";

        var pre = await ResMgr.Instance.IE_GetAsset(AbNames.Game,path,cc.Prefab);
        console.log("========GameApp pre================",pre);

        await UIMgr.Instance.ShopwUIAt(AbNames.Game,path,cc.Prefab)

      

    }
}
